package test;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;

public class MyJFram extends JFrame implements ActionListener {
    JButton jButton1 = new JButton("jbt1");
    JButton jButton2 = new JButton("jbt2");
    public MyJFram(){
        this.setSize(600,500);
        this.setAlwaysOnTop(true);
        this.setDefaultCloseOperation(3);
        this.setLayout(null);
        this.setLocationRelativeTo(null);
        jButton1.setBounds(0,0,100,100);
        jButton1.addActionListener(this);
        jButton2.setBounds(20,0,100,100);
        jButton2.addActionListener(this);
        this.getContentPane().add(jButton1);
        this.getContentPane().add(jButton2);
        this.setVisible(true);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        Object source = e.getSource();
        Random r = new Random();
        if(source==jButton1)
        {
            jButton1.setSize(r.nextInt(500),r.nextInt(500));
        }
        else
        {
            jButton2.setLocation(r.nextInt(500),r.nextInt(500));
        }
    }
}
